int TreeSize(struct TreeNode* root)
{
    if(root==NULL)
    return 0;
    return 1+TreeSize(root->left)+TreeSize(root->right);
}


void preOrder(struct TreeNode* root,int *a,int* i)
{
    if(root==NULL)
    return ;
    
    a[(*i)++]=root->val;
    preOrder(root->left,a,i);
    preOrder(root->right,a,i);
}


int* preorderTraversal(struct TreeNode* root, int* returnSize) {
    int n=TreeSize(root);
    int *a = (int*)malloc(sizeof(int)*n);
    *returnSize=n;
}